#!/usr/bin/env bash

set -eux

shopt -s nullglob

rsync -amv /source/package/ /usr/src/buildroot/package/

pushd /usr/src/buildroot
for PATCH in /source/patches/*.patch; do
  patch -t -p1 -i "${PATCH}"
done
popd

cat /source/buildroot/{"${BUILDARCH}config",config} > /usr/src/buildroot/.config
